package com.example.xd.javatest.java_rx_test;

import java.util.ArrayList;
import java.util.List;

/**
 * @auther XuDan on 2020/6/22.
 */
public class ObservableCreator implements Observable {
    List<Observer> mList;


    public ObservableCreator() {
        mList = new ArrayList<>();
    }

    @Override
    public void add(Observer observer) {
        mList.add(observer);
    }

    @Override
    public void remove(Observer observer) {
        mList.remove(observer);
    }

    private String s;

    public void setData(String s) {
        this.s = s;
        notification();
    }

    @Override
    public void notification() {
        for (Observer observer : mList) {
            observer.upData(s);
        }
    }
}
